490A - Team Olympiad - CodeForces Solution


greedy implementation sortings *800

Please click on ads to support us..

Python Code:

if __name__ == '__main__':
    n = int(input())
    x = input().split()
    li = [int(i) for i in x]
    m1 = 0
    m2 = 0
    m3 = 0

    for i in li:
        if i == 1:
            m1 += 1
        elif i == 2:
            m2 += 1
        else:
            m3 += 1
    count = min(m1, m2, m3)

    if count == 0:
        print(0)
    else:
        l1 = []
        l2 = []
        l3 = []
        for i in range(0, len(li)):
            if li[i] == 1:
                l1.append(i + 1)
            elif li[i] == 2:
                l2.append(i + 1)
            else:
                l3.append(i + 1)

        print(count)
        for i in range(0, count):
            print(l1[i], l2[i], l3[i])


Comments

Submit
0 Comments
More Questions

1705A - Mark the Photographer
1707A - Doremy's IQ
1706B - Making Towers
1325B - CopyCopyCopyCopyCopy
1649C - Weird Sum
1324B - Yet Another Palindrome Problem
525A - Vitaliy and Pie
879A - Borya's Diagnosis
1672B - I love AAAB
1673A - Subtle Substring Subtraction
1345A - Puzzle Pieces
711A - Bus to Udayland
779B - Weird Rounding
1703D - Double Strings
1704C - Virus
63A - Sinking Ship
1704B - Luke is a Foodie
298B - Sail
239A - Two Bags of Potatoes
1704E - Count Seconds
682A - Alyona and Numbers
44A - Indian Summer
1133C - Balanced Team
1704A - Two 0-1 Sequences
1467A - Wizard of Orz
1714E - Add Modulo 10
1714A - Everyone Loves to Sleep
764A - Taymyr is calling you
1714B - Remove Prefix
1264F - Beautiful Fibonacci Problem